// pages/user/income.js
import { User } from '../../model/user.js';
import { UserMoney } from '../../model/user-money.js';
var user = new User();
var user_money = new UserMoney();
Page({

  /**
   * 页面的初始数据
   */
  data: {
      hidden: false,
      show: false,
      currentDate: new Date().getTime(),
      maxDate: new Date().getTime(),
      userInfo: {},
      minMoney: '',
      maxMoney: '',
      userMoney: '',
      dateString: '',
      time: '',
      list: [],
  }, 
  onInput(event) {
    this.setData({
      currentDate: event.detail,
      time: event.detail
    });
    wx.showLoading({
      title: '加载中',
    });
    this.getUserMoney()
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({
      title: '加载中',
    });
    this.getUserInfo();
  },
  /**
   * 获取用户信息
   */
  getUserInfo() {
    user.getUserInfo((result) => {
      this.setData({
        userInfo: result,
      })
      this.getUserMoney()
    })
  },
  getUserMoney() {
    user_money.getUserMoney(this.data.time,(result)=>{
      this.setData({
        list: result.data,
        dateString: result.date,
        hidden: true,
        max_money: result.max_money,
        min_money: result.min_money,
        user_money: result.user_money,
      })
      wx.hideLoading();
    })
  },
  openShow(){
    this.setData({
      show: true
    })
  },
  onClickHide(){
    this.setData({
      show: false
    })
  }
})